<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="common/taglibs.jsp" %>
<html>
<head>
    <title>MainMenu</title>
    <%@ include file="common/meta.jsp" %>
    <link rel="stylesheet" href="${rootPath}/resources/css/demo.css" type="text/css">
    <link rel="stylesheet" href="${rootPath}/resources/css/zTreeStyle/zTreeStyle.css" type="text/css">
    <script type="text/javascript" src="${rootPath}/resources/js/jquery.min.js"></script>
    <script type="text/javascript" src="${rootPath}/resources/js/jquery.ztree.all.js"></script>
</head>
<body>
<h3 class='title'>example site: MainMenu </h3>
<script type="text/javascript">
    <!--
    var setting = {
        data: {
            simpleData: {
                enable: true
            }
        },
        callback: {
            onClick: onClick
        }
    };


    var childwindow = new Array();
    var count = 0;

    function openWindow(obj){
        var opt='toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes';
        var d=(new Date()).getTime();

        var menutitle = "test";
        menutitle = menutitle+""+d;

        var w=window.open(obj,menutitle,opt,false);
        childwindow[count]=w;
        count++;
    }

    function closeWindow(){
        for(i=0;i<count;i++){
            var win=childwindow[i];
            if(win !=null)win.close();
        }
    }


    function onClick(event, treeId, treeNode, clickFlag) {
        openWindow(treeNode.menuUrl);
    }

    window.onbeforeunload = function (e) {
        closeWindow();

        $.ajax({
            url:'${rootPath}/logout',
            type:'get',
            success:function(result){

            }
        });
        window.setTimeout(function(){
        },2000);
    };
    //$(window).bind("beforeunload", function() {
    //    return true ||  confirm("程序退出");
    // });

    function logout(){
        var flag = confirm("程序退出");

        return flag;
    }



    var zNodes =[
        { id:1, pId:0, name:"展开、折叠 自定义图标不同", open:true, iconSkin:"pIcon01" },
        { id:11, pId:1, name:"测试", iconSkin:"icon01",menuUrl:"${rootPath}/test"},
        { id:11, pId:1, name:"系统用户管理", iconSkin:"icon01",menuUrl:"${rootPath}/sys/user/user_main_start01"},
        { id:12, pId:1, name:"叶子节点2", iconSkin:"icon02",target:"_blank",url:""},
        { id:13, pId:1, name:"叶子节点3", iconSkin:"icon03",target:"_blank",url:""},
        { id:2, pId:0, name:"展开、折叠 自定义图标相同", open:true, iconSkin:"pIcon02"},
        { id:21, pId:2, name:"叶子节点1", iconSkin:"icon04"},
        { id:22, pId:2, name:"叶子节点2", iconSkin:"icon05"},
        { id:23, pId:2, name:"叶子节点3", iconSkin:"icon06"},
        { id:3, pId:0, name:"不使用自定义图标", open:true },
        { id:31, pId:3, name:"叶子节点1"},
        { id:32, pId:3, name:"叶子节点2"},
        { id:33, pId:3, name:"叶子节点3"}
    ];

    $(document).ready(function(){
        $.fn.zTree.init($("#treeDemo"), setting, zNodes);
    });
    //-->
</script>
<style type="text/css">
    .ztree li span.button.pIcon01_ico_open{margin-right:2px; background: url(${rootPath}/resources/css/zTreeStyle/img/diy/1_open.png) no-repeat scroll 0 0 transparent; vertical-align:top; *vertical-align:middle}
    .ztree li span.button.pIcon01_ico_close{margin-right:2px; background: url(${rootPath}/resources/css/zTreeStyle/img/diy/1_close.png) no-repeat scroll 0 0 transparent; vertical-align:top; *vertical-align:middle}
    .ztree li span.button.pIcon02_ico_open, .ztree li span.button.pIcon02_ico_close{margin-right:2px; background: url(${rootPath}/resources/css/zTreeStyle/img/diy/2.png) no-repeat scroll 0 0 transparent; vertical-align:top; *vertical-align:middle}
    .ztree li span.button.icon01_ico_docu{margin-right:2px; background: url(${rootPath}/resources/css/zTreeStyle/img/diy/3.png) no-repeat scroll 0 0 transparent; vertical-align:top; *vertical-align:middle}
    .ztree li span.button.icon02_ico_docu{margin-right:2px; background: url(${rootPath}/resources/css/zTreeStyle/img/diy/4.png) no-repeat scroll 0 0 transparent; vertical-align:top; *vertical-align:middle}
    .ztree li span.button.icon03_ico_docu{margin-right:2px; background: url(${rootPath}/resources/css/zTreeStyle/img/diy/5.png) no-repeat scroll 0 0 transparent; vertical-align:top; *vertical-align:middle}
    .ztree li span.button.icon04_ico_docu{margin-right:2px; background: url(${rootPath}/resources/css/zTreeStyle/img/diy/6.png) no-repeat scroll 0 0 transparent; vertical-align:top; *vertical-align:middle}
    .ztree li span.button.icon05_ico_docu{margin-right:2px; background: url(${rootPath}/resources/css/zTreeStyle/img/diy/7.png) no-repeat scroll 0 0 transparent; vertical-align:top; *vertical-align:middle}
    .ztree li span.button.icon06_ico_docu{margin-right:2px; background: url(${rootPath}/resources/css/zTreeStyle/img/diy/8.png) no-repeat scroll 0 0 transparent; vertical-align:top; *vertical-align:middle}
</style>
<div class="zTreeDemoBackground left">
    <ul id="treeDemo" class="ztree"></ul>
</div>

</body>
</html>
